//#include "StdAfx.h"
#include ".\myui_cedit.h"

myui_CEdit::myui_CEdit(void)
{
	isPassword = false;
	isNumber = false;
	isRead = false;
}

myui_CEdit::~myui_CEdit(void)
{
	if (m_edit)
		RemoveCustomEdit(m_edit);
}

void myui_CEdit::setX(int x)
{
	m_x = x;
	if (m_edit)
	{
		RemoveCustomEdit(m_edit);
		Init(m_x, m_y, m_width, m_height);
	}
}

void myui_CEdit::setY(int y)
{
	m_y = y;
	if (m_edit)
	{
		RemoveCustomEdit(m_edit);
		Init(m_x, m_y, m_width, m_height);
	}
}

void myui_CEdit::Show(void)
{
	if (m_edit == NULL)
		return;
	m_edit->Show();
}

void myui_CEdit::Hide(void)
{
	if (m_edit == NULL)
		return;
	m_edit->Hide();
}

bool myui_CEdit::SetString(char * str)
{
	if (m_edit == NULL)
		return false;
	m_edit->SetString(str);
	return true;
}

char* myui_CEdit::GetString()
{
	if (m_edit == NULL)
		return NULL;
	return m_edit->GetString();
}

int myui_CEdit::GetInt()
{
	return atoi(m_edit->GetString());
}
bool myui_CEdit::Init(int x, int y, int w, int h)
{
	m_x = x;
	m_y = y;
	m_width = w;
	m_height = h;
	m_edit = CreateCustomEdit(hoho.m_hWnd, GetGraphics(), getParentX(), getParentY(), m_width, m_height);
	if (m_edit == NULL)
		return false;
	return true;
}

bool myui_CEdit::Init(LP_INI_FILE ini, char * ItemCaption)
{
	if (ini == NULL)
		return false;

	m_x = ini->GetItemInt(ItemCaption, "x");
	m_y = ini->GetItemInt(ItemCaption, "y");
	m_width = ini->GetItemInt(ItemCaption, "w");
	m_height = ini->GetItemInt(ItemCaption, "h");
	if (ini->GetItemInt(ItemCaption, "password") == 1)
		isPassword = true;
	else
		isPassword = false;

	if (ini->GetItemInt(ItemCaption, "number") == 1)
		isNumber = true;
	else
		isNumber = false;

	if (ini->GetItemInt(ItemCaption, "read") == 1)
		isRead = true;
	else
		isRead = false;

	if (m_edit != NULL)
		RemoveCustomEdit(m_edit);
	m_edit = CreateCustomEdit(hoho.m_hWnd, GetGraphics(), getParentX() + m_x, getParentY() + m_y, m_width, m_height, isPassword, true, isNumber, isRead);
	if (m_edit == NULL)
		return false;
	return true;
}